﻿<UserControl x:Class="PHPVHReportViewer.Views.DynamicAnalysisVulnerabilityControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <TabControl>
        <TabItem>
            <TabItem.Header>
                <TextBlock Text="Alert Overview" />
            </TabItem.Header>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBox Text="{Binding Item.AlertName}" Margin="0,0,0,2" 
                                         VerticalAlignment="Center"
                                         Background="Transparent" />

                <TextBox Grid.Row="1" Text="{Binding Item.Trace.Request}"
                                                 Background="Transparent"
                                                 VerticalScrollBarVisibility="Auto"
                                                 HorizontalScrollBarVisibility="Auto"/>

                <TextBox Margin="0,4,0,0"  Grid.Row="2" Text="{Binding Item.Trace.Response}"
                                                 Background="Transparent"
                                                 VerticalScrollBarVisibility="Auto"
                                                 HorizontalScrollBarVisibility="Auto"/>
                <GridSplitter Grid.Row="2" VerticalAlignment="Top" Height="4"
                                              Background="Transparent"
                                              HorizontalAlignment="Stretch"/>
            </Grid>
        </TabItem>
        <TabItem Header="Captured Data">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Expander>
                    <Expander.Header>
                        <TextBlock FontWeight="Bold" Text="Filters" />
                    </Expander.Header>
                    <Grid Margin="4">
                        <Grid.Resources>
                            <Style TargetType="CheckBox">
                                <Setter Property="VerticalAlignment" Value="Center" />
                            </Style>
                            <Style TargetType="TextBox">
                                <Setter Property="Margin" Value="4" />
                                <Setter Property="VerticalAlignment" Value="Center" />
                                <Setter Property="VerticalContentAlignment" Value="Center" />
                            </Style>
                            <Style TargetType="TextBlock">
                                <Setter Property="VerticalAlignment" Value="Center" />
                                <Setter Property="FontWeight" Value="Bold" />
                                <Setter Property="Margin" Value="6,0,6,0" />
                            </Style>
                        </Grid.Resources>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="121" />
                            <ColumnDefinition Width="128" />
                            <ColumnDefinition Width="128" />
                        </Grid.ColumnDefinitions>

                        <CheckBox Grid.Row="0" IsChecked="{Binding NameFilterEnabled}">
                            <TextBlock Text="Name Contains" />
                        </CheckBox>
                        <TextBox Grid.Column="1" Grid.Row="0" Width="120"
                                                         Text="{Binding NameFilter,UpdateSourceTrigger=PropertyChanged}"
                                                         IsEnabled="{Binding NameFilterEnabled}"/>

                        <CheckBox Grid.Row="1" IsChecked="{Binding ParamFilterEnabled}">
                            <TextBlock Text="Param Contains" />
                        </CheckBox>
                        <TextBox Grid.Column="1" Grid.Row="1" Width="120"
                                                         Text="{Binding ParamFilter,UpdateSourceTrigger=PropertyChanged}"
                                                         IsEnabled="{Binding ParamFilterEnabled}"/>

                        <CheckBox Grid.Row="2" IsChecked="{Binding ReturnFilterEnabled}">
                            <TextBlock Text="Return Contains" />
                        </CheckBox>
                        <TextBox Grid.Column="1" Grid.Row="2" Width="120"
                                                         Text="{Binding ReturnFilter,UpdateSourceTrigger=PropertyChanged}"
                                                         IsEnabled="{Binding ReturnFilterEnabled}"/>

                        <Button Content="Apply" Grid.Row="1" Grid.RowSpan="2"
                                                        Grid.Column="3" VerticalAlignment="Bottom"
                                                        HorizontalAlignment="Right"
                                                        Click="ApplyFilterButton_Click"/>


                    </Grid>
                </Expander>
                <!--</Border>-->
                <ScrollViewer Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <ItemsControl ItemsSource="{Binding Calls}" Background="Transparent"
                                                  ScrollViewer.CanContentScroll="False">
                        <ItemsControl.ItemContainerStyle>
                            <Style>
                                <Setter Property="ContentControl.HorizontalContentAlignment" Value="Stretch" />
                            </Style>
                        </ItemsControl.ItemContainerStyle>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Border CornerRadius="4" BorderThickness="2" Background="Transparent"
                                                                BorderBrush="DarkGray" Margin="4">
                                    <StackPanel Margin="4">
                                        <StackPanel>
                                            <TextBlock Text="Name" FontWeight="Bold" />
                                            <TextBox Text="{Binding Name}"
                                                                             Background="Transparent" />
                                        </StackPanel>
                                        <StackPanel Margin="0,6,0,0">
                                            <TextBlock Text="Parameter Values" FontWeight="Bold" />
                                            <ItemsControl ItemsSource="{Binding ParameterValues}" 
                                                                                  MaxHeight="300">
                                                <ItemsControl.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBox Text="{Binding Mode=OneWay}"
                                                                                         Background="Transparent" />
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </StackPanel>
                                        <StackPanel Margin="0,6,0,0">
                                            <TextBlock Text="Return Value" FontWeight="Bold" />
                                            <TextBox Text="{Binding Value}"
                                                                             Background="Transparent" />
                                        </StackPanel>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ScrollViewer>
            </Grid>

        </TabItem>
    </TabControl>
</UserControl>
